﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Net.Mail;
using System.Text;

public partial class Pages_Admin_SubInfoListTest :NoTheme
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void emailSearch_Click(object sender, EventArgs e)
    {

    }
    protected void emailSend_Click(object sender, EventArgs e)
    {
        MailMessage sendMail = new MailMessage();
        sendMail.From = new MailAddress("service@5151tuan.com");
        foreach (object item in emailShow.Items)
            sendMail.Bcc.Add(item.ToString());
        sendMail.Subject = MainTitle.Text;
        sendMail.Body = emailContent.Text;
        sendMail.BodyEncoding = Encoding.UTF8;
        sendMail.IsBodyHtml = true;
        sendMail.Priority = MailPriority.Normal;

        SmtpClient sendClient = new SmtpClient("smtp.ym.163.com", 25);
        sendClient.DeliveryMethod = SmtpDeliveryMethod.Network;//service@5151tuan.com 
        sendClient.Credentials = new System.Net.NetworkCredential("service@5151tuan.com", "5151tuanservice");
        sendClient.Timeout = 60000;
        try
        {
            sendClient.Send(sendMail);
            Response.Write("<script>alert('success')</script>");
        }
        catch(Exception ex)
        {
            Pan.Log.WriteLog(ex.Source+ex.Message, "Email");
            Response.Write("<script>alert('fail')</script>");
        }
    }
}

